package com.lagou.edu.controller;

import com.lagou.edu.service.LagouAuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 邮件控制器
 */
@RestController
@RequestMapping({"/code",""})
@RefreshScope
public class CodeController {

    @Autowired
    LagouAuthCodeService lagouAuthCodeService;

    @GetMapping("create/{email}")
    public boolean create(@PathVariable("email") String email){
        return lagouAuthCodeService.create(email);
    }

    @GetMapping("validate/{email}/{code}")
    public int validate(@PathVariable("email") String email, @PathVariable("code") String code){
       return lagouAuthCodeService.validate(email,code);
    }

}
